package com.marketingexpert.controller.statemgnt;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import com.marketingexpert.domain.User;
import com.marketingexpert.service.statreport.StatReportService;
import com.marketingexpert.service.usermgnt.UserService;

public class QueryActivityTotalController implements Controller {

	private StatReportService statReportService;

	private UserService userService;
	
	@Override
	public ModelAndView handleRequest(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		response.setContentType("text/html;charset=GBK"); 
		response.setHeader("Pragma", "No-cache"); 
		response.setHeader("Cache-Control", "no-cache"); 
		response.setHeader("Cache-Control", "no-store"); 
		response.setDateHeader("Expires", 0);  
		PrintWriter out = response.getWriter(); 
		String parentUserId = (String) request.getSession().getAttribute(
		"parentUserId");
		User parentUser = getUserService().queryUserByUId(parentUserId);
		int activityTotal = getStatReportService().queryActivityRecordCount(parentUser.getId());		
		out.print(activityTotal);		
		return null;
	}

	public StatReportService getStatReportService() {
		return statReportService;
	}

	public void setStatReportService(StatReportService statReportService) {
		this.statReportService = statReportService;
	}

	public UserService getUserService() {
		return userService;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}
	
	

}
